home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1993 July / InfoMagic USENET CD-ROM July 1993.ISO / sources / unix / volume10 / ptoc / part04 < prev    next >
Encoding:
Internet Message Format  |  1987-07-26  |  36.9 KB

  1. Path: uunet!rs
  2. From: rs@uunet.UU.NET (Rich Salz)
  3. Newsgroups: comp.sources.unix
  4. Subject: v10i068:  Pascal to C translator, Part04/12
  5. Message-ID: <707@uunet.UU.NET>
  6. Date: 27 Jul 87 23:08:03 GMT
  7. Organization: UUNET Communications Services, Arlington, VA
  8. Lines: 1546
  9. Approved: rs@uunet.UU.NET
  10.  
  11. Submitted-by: Per Bergsten <mcvax!enea!chalmers!holtec!perb>
  12. Posting-number: Volume 10, Issue 68
  13. Archive-name: ptoc/Part04
  14.  
  15. #! /bin/sh
  16. # This is a shell archive.  Remove anything before this line, then unpack
  17. # it by saving it into a file and typing "sh file".  To overwrite existing
  18. # files, type "sh file -c".  You can also feed this as standard input via
  19. # unshar, or by typing "sh <file", e.g..  If this archive is complete, you
  20. # will see the following message at the end:
  21. #        "End of archive 4 (of 12)."
  22. # Contents:  ptc.c.2
  23. PATH=/bin:/usr/bin:/usr/ucb ; export PATH
  24. if test -f 'ptc.c.2' -a "${1}" != "-c" ; then 
  25.   echo shar: Will not clobber existing file \"'ptc.c.2'\"
  26. else
  27. echo shar: Extracting \"'ptc.c.2'\" \(34509 characters\)
  28. sed "s/^X//" >'ptc.c.2' <<'END_OF_FILE'
  29. X            tf = typnods.A[(int)(tset)];
  30. X            break ;
  31. X          case nselect:
  32. X            tq = tq->U.V40.tfield;
  33. X            break ;
  34. X          case nderef:
  35. X            tq = typeof(tq->U.V42.texps);
  36. X            switch (tq->tt) {
  37. X              case nptr:
  38. X                tq = tq->U.V16.tptrid;
  39. X                break ;
  40. X              case nfileof:
  41. X                tq = tq->U.V18.tof;
  42. X                break ;
  43. X              case npredef:
  44. X                tf = typnods.A[(int)(tchar)];
  45. X                break ;
  46. X              default:
  47. X                Caseerror(Line);
  48. X            }
  49. X            break ;
  50. X          case nindex:
  51. X            tq = typeof(tq->U.V39.tvariable);
  52. X            if (tq->tt == nconfarr)
  53. X                tq = tq->U.V22.tcelem;
  54. X            else
  55. X                if (tq == typnods.A[(int)(tstring)])
  56. X                    tf = typnods.A[(int)(tchar)];
  57. X                else
  58. X                    tq = tq->U.V23.taelem;
  59. X            break ;
  60. X          default:
  61. X            Caseerror(Line);
  62. X        }
  63. X    }
  64. X    if (tp->ttype == (struct S61 *)NIL)
  65. X        tp->ttype = tf;
  66. X    R92 = tf;
  67. X    return R92;
  68. X}
  69. X
  70. X void
  71. Xlinkup(up, tp)
  72. X    treeptr    up, tp;
  73. X{
  74. X    while (tp != (struct S61 *)NIL) {
  75. X        if (tp->tup == (struct S61 *)NIL) {
  76. X            tp->tup = up;
  77. X            switch (tp->tt) {
  78. X              case npgm:  case nfunc:  case nproc:
  79. X                linkup(tp, tp->U.V13.tsubid);
  80. X                linkup(tp, tp->U.V13.tsubpar);
  81. X                linkup(tp, tp->U.V13.tfuntyp);
  82. X                linkup(tp, tp->U.V13.tsublab);
  83. X                linkup(tp, tp->U.V13.tsubconst);
  84. X                linkup(tp, tp->U.V13.tsubtype);
  85. X                linkup(tp, tp->U.V13.tsubvar);
  86. X                linkup(tp, tp->U.V13.tsubsub);
  87. X                linkup(tp, tp->U.V13.tsubstmt);
  88. X                break ;
  89. X              case nvalpar:  case nvarpar:  case nconst:  case ntype:
  90. X              case nfield:  case nvar:
  91. X                linkup(tp, tp->U.V14.tidl);
  92. X                linkup(tp, tp->U.V14.tbind);
  93. X                break ;
  94. X              case nparproc:  case nparfunc:
  95. X                linkup(tp, tp->U.V15.tparid);
  96. X                linkup(tp, tp->U.V15.tparparm);
  97. X                linkup(tp, tp->U.V15.tpartyp);
  98. X                break ;
  99. X              case nptr:
  100. X                linkup(tp, tp->U.V16.tptrid);
  101. X                break ;
  102. X              case nscalar:
  103. X                linkup(tp, tp->U.V17.tscalid);
  104. X                break ;
  105. X              case nsubrange:
  106. X                linkup(tp, tp->U.V19.tlo);
  107. X                linkup(tp, tp->U.V19.thi);
  108. X                break ;
  109. X              case nvariant:
  110. X                linkup(tp, tp->U.V20.tselct);
  111. X                linkup(tp, tp->U.V20.tvrnt);
  112. X                break ;
  113. X              case nrecord:
  114. X                linkup(tp, tp->U.V21.tflist);
  115. X                linkup(tp, tp->U.V21.tvlist);
  116. X                break ;
  117. X              case nconfarr:
  118. X                linkup(tp, tp->U.V22.tcindx);
  119. X                linkup(tp, tp->U.V22.tcelem);
  120. X                linkup(tp, tp->U.V22.tindtyp);
  121. X                break ;
  122. X              case narray:
  123. X                linkup(tp, tp->U.V23.taindx);
  124. X                linkup(tp, tp->U.V23.taelem);
  125. X                break ;
  126. X              case nfileof:  case nsetof:
  127. X                linkup(tp, tp->U.V18.tof);
  128. X                break ;
  129. X              case nbegin:
  130. X                linkup(tp, tp->U.V24.tbegin);
  131. X                break ;
  132. X              case nlabstmt:
  133. X                linkup(tp, tp->U.V25.tlabno);
  134. X                linkup(tp, tp->U.V25.tstmt);
  135. X                break ;
  136. X              case nassign:
  137. X                linkup(tp, tp->U.V27.tlhs);
  138. X                linkup(tp, tp->U.V27.trhs);
  139. X                break ;
  140. X              case npush:  case npop:
  141. X                linkup(tp, tp->U.V28.tglob);
  142. X                linkup(tp, tp->U.V28.tloc);
  143. X                linkup(tp, tp->U.V28.ttmp);
  144. X                break ;
  145. X              case ncall:
  146. X                linkup(tp, tp->U.V30.tcall);
  147. X                linkup(tp, tp->U.V30.taparm);
  148. X                break ;
  149. X              case nif:
  150. X                linkup(tp, tp->U.V31.tifxp);
  151. X                linkup(tp, tp->U.V31.tthen);
  152. X                linkup(tp, tp->U.V31.telse);
  153. X                break ;
  154. X              case nwhile:
  155. X                linkup(tp, tp->U.V32.twhixp);
  156. X                linkup(tp, tp->U.V32.twhistmt);
  157. X                break ;
  158. X              case nrepeat:
  159. X                linkup(tp, tp->U.V33.treptstmt);
  160. X                linkup(tp, tp->U.V33.treptxp);
  161. X                break ;
  162. X              case nfor:
  163. X                linkup(tp, tp->U.V34.tforid);
  164. X                linkup(tp, tp->U.V34.tfrom);
  165. X                linkup(tp, tp->U.V34.tto);
  166. X                linkup(tp, tp->U.V34.tforstmt);
  167. X                break ;
  168. X              case ncase:
  169. X                linkup(tp, tp->U.V35.tcasxp);
  170. X                linkup(tp, tp->U.V35.tcaslst);
  171. X                linkup(tp, tp->U.V35.tcasother);
  172. X                break ;
  173. X              case nchoise:
  174. X                linkup(tp, tp->U.V36.tchocon);
  175. X                linkup(tp, tp->U.V36.tchostmt);
  176. X                break ;
  177. X              case nwith:
  178. X                linkup(tp, tp->U.V37.twithvar);
  179. X                linkup(tp, tp->U.V37.twithstmt);
  180. X                break ;
  181. X              case nwithvar:
  182. X                linkup(tp, tp->U.V38.texpw);
  183. X                break ;
  184. X              case nindex:
  185. X                linkup(tp, tp->U.V39.tvariable);
  186. X                linkup(tp, tp->U.V39.toffset);
  187. X                break ;
  188. X              case nselect:
  189. X                linkup(tp, tp->U.V40.trecord);
  190. X                linkup(tp, tp->U.V40.tfield);
  191. X                break ;
  192. X              case ngoto:
  193. X                linkup(tp, tp->U.V26.tlabel);
  194. X                break ;
  195. X              case nrange:  case nformat:  case nin:  case neq:
  196. X              case nne:  case nlt:  case nle:  case ngt:
  197. X              case nge:  case nor:  case nplus:  case nminus:
  198. X              case nand:  case nmul:  case ndiv:  case nmod:
  199. X              case nquot:
  200. X                linkup(tp, tp->U.V41.texpl);
  201. X                linkup(tp, tp->U.V41.texpr);
  202. X                break ;
  203. X              case nderef:  case nnot:  case nset:  case numinus:
  204. X              case nuplus:
  205. X                linkup(tp, tp->U.V42.texps);
  206. X                break ;
  207. X              case nid:  case nnil:  case ninteger:  case nreal:
  208. X              case nchar:  case nstring:  case npredef:  case nlabel:
  209. X              case nempty:
  210. X                break ;
  211. X              default:
  212. X                Caseerror(Line);
  213. X            }
  214. X        }
  215. X        tp = tp->tnext;
  216. X    }
  217. X}
  218. X
  219. X symptr
  220. Xmksym(vt)
  221. X    ltypes    vt;
  222. X{
  223. X    register symptr    R93;
  224. X    symptr    mp;
  225. X
  226. X    mp = (struct S62 *)malloc((unsigned)(sizeof(*mp)));
  227. X    if (mp == (struct S62 *)NIL)
  228. X        error(enew);
  229. X    mp->lt = vt;
  230. X    mp->lnext = (struct S62 *)NIL;
  231. X    mp->lsymdecl = (struct S61 *)NIL;
  232. X    mp->ldecl = (struct S60 *)NIL;
  233. X    R93 = mp;
  234. X    return R93;
  235. X}
  236. X
  237. X void
  238. Xdeclsym(sp)
  239. X    symptr    sp;
  240. X{
  241. X    hashtyp    h;
  242. X
  243. X    if (Member((unsigned)(sp->lt), Conset[1]))
  244. X        h = sp->U.V6.lid->ihash;
  245. X    else
  246. X        h = hashmax;
  247. X    sp->lnext = symtab->ddecl.A[h];
  248. X    symtab->ddecl.A[h] = sp;
  249. X    sp->ldecl = symtab;
  250. X}
  251. X
  252. X treeptr
  253. Xmknode(nt)
  254. X    treetyp    nt;
  255. X{
  256. X    register treeptr    R94;
  257. X    treeptr    tp;
  258. X
  259. X    tp = (struct S61 *)NIL;
  260. X    switch (nt) {
  261. X      case npredef:
  262. X        tp = (struct S61 *)malloc((unsigned)(Unionoffs(tp, U.V12.tdef) + sizeof(tp->U.V12)));
  263. X        break ;
  264. X      case npgm:
  265. X        tp = (struct S61 *)malloc((unsigned)(Unionoffs(tp, U.V13.tsubid) + sizeof(tp->U.V13)));
  266. X        break ;
  267. X      case nfunc:
  268. X        tp = (struct S61 *)malloc((unsigned)(Unionoffs(tp, U.V13.tsubid) + sizeof(tp->U.V13)));
  269. X        break ;
  270. X      case nproc:
  271. X        tp = (struct S61 *)malloc((unsigned)(Unionoffs(tp, U.V13.tsubid) + sizeof(tp->U.V13)));
  272. X        break ;
  273. X      case nlabel:
  274. X        tp = (struct S61 *)malloc((unsigned)(Unionoffs(tp, U.V43.tsym) + sizeof(tp->U.V43)));
  275. X        break ;
  276. X      case nconst:
  277. X        tp = (struct S61 *)malloc((unsigned)(Unionoffs(tp, U.V14.tidl) + sizeof(tp->U.V14)));
  278. X        break ;
  279. X      case ntype:
  280. X        tp = (struct S61 *)malloc((unsigned)(Unionoffs(tp, U.V14.tidl) + sizeof(tp->U.V14)));
  281. X        break ;
  282. X      case nvar:
  283. X        tp = (struct S61 *)malloc((unsigned)(Unionoffs(tp, U.V14.tidl) + sizeof(tp->U.V14)));
  284. X        break ;
  285. X      case nvalpar:
  286. X        tp = (struct S61 *)malloc((unsigned)(Unionoffs(tp, U.V14.tidl) + sizeof(tp->U.V14)));
  287. X        break ;
  288. X      case nvarpar:
  289. X        tp = (struct S61 *)malloc((unsigned)(Unionoffs(tp, U.V14.tidl) + sizeof(tp->U.V14)));
  290. X        break ;
  291. X      case nparproc:
  292. X        tp = (struct S61 *)malloc((unsigned)(Unionoffs(tp, U.V15.tparid) + sizeof(tp->U.V15)));
  293. X        break ;
  294. X      case nparfunc:
  295. X        tp = (struct S61 *)malloc((unsigned)(Unionoffs(tp, U.V15.tparid) + sizeof(tp->U.V15)));
  296. X        break ;
  297. X      case nsubrange:
  298. X        tp = (struct S61 *)malloc((unsigned)(Unionoffs(tp, U.V19.tlo) + sizeof(tp->U.V19)));
  299. X        break ;
  300. X      case nvariant:
  301. X        tp = (struct S61 *)malloc((unsigned)(Unionoffs(tp, U.V20.tselct) + sizeof(tp->U.V20)));
  302. X        break ;
  303. X      case nfield:
  304. X        tp = (struct S61 *)malloc((unsigned)(Unionoffs(tp, U.V14.tidl) + sizeof(tp->U.V14)));
  305. X        break ;
  306. X      case nrecord:
  307. X        tp = (struct S61 *)malloc((unsigned)(Unionoffs(tp, U.V21.tflist) + sizeof(tp->U.V21)));
  308. X        break ;
  309. X      case nconfarr:
  310. X        tp = (struct S61 *)malloc((unsigned)(Unionoffs(tp, U.V22.tcindx) + sizeof(tp->U.V22)));
  311. X        break ;
  312. X      case narray:
  313. X        tp = (struct S61 *)malloc((unsigned)(Unionoffs(tp, U.V23.taindx) + sizeof(tp->U.V23)));
  314. X        break ;
  315. X      case nfileof:
  316. X        tp = (struct S61 *)malloc((unsigned)(Unionoffs(tp, U.V18.tof) + sizeof(tp->U.V18)));
  317. X        break ;
  318. X      case nsetof:
  319. X        tp = (struct S61 *)malloc((unsigned)(Unionoffs(tp, U.V18.tof) + sizeof(tp->U.V18)));
  320. X        break ;
  321. X      case nbegin:
  322. X        tp = (struct S61 *)malloc((unsigned)(Unionoffs(tp, U.V24.tbegin) + sizeof(tp->U.V24)));
  323. X        break ;
  324. X      case nptr:
  325. X        tp = (struct S61 *)malloc((unsigned)(Unionoffs(tp, U.V16.tptrid) + sizeof(tp->U.V16)));
  326. X        break ;
  327. X      case nscalar:
  328. X        tp = (struct S61 *)malloc((unsigned)(Unionoffs(tp, U.V17.tscalid) + sizeof(tp->U.V17)));
  329. X        break ;
  330. X      case nif:
  331. X        tp = (struct S61 *)malloc((unsigned)(Unionoffs(tp, U.V31.tifxp) + sizeof(tp->U.V31)));
  332. X        break ;
  333. X      case nwhile:
  334. X        tp = (struct S61 *)malloc((unsigned)(Unionoffs(tp, U.V32.twhixp) + sizeof(tp->U.V32)));
  335. X        break ;
  336. X      case nrepeat:
  337. X        tp = (struct S61 *)malloc((unsigned)(Unionoffs(tp, U.V33.treptstmt) + sizeof(tp->U.V33)));
  338. X        break ;
  339. X      case nfor:
  340. X        tp = (struct S61 *)malloc((unsigned)(Unionoffs(tp, U.V34.tforid) + sizeof(tp->U.V34)));
  341. X        break ;
  342. X      case ncase:
  343. X        tp = (struct S61 *)malloc((unsigned)(Unionoffs(tp, U.V35.tcasxp) + sizeof(tp->U.V35)));
  344. X        break ;
  345. X      case nchoise:
  346. X        tp = (struct S61 *)malloc((unsigned)(Unionoffs(tp, U.V36.tchocon) + sizeof(tp->U.V36)));
  347. X        break ;
  348. X      case ngoto:
  349. X        tp = (struct S61 *)malloc((unsigned)(Unionoffs(tp, U.V26.tlabel) + sizeof(tp->U.V26)));
  350. X        break ;
  351. X      case nwith:
  352. X        tp = (struct S61 *)malloc((unsigned)(Unionoffs(tp, U.V37.twithvar) + sizeof(tp->U.V37)));
  353. X        break ;
  354. X      case nwithvar:
  355. X        tp = (struct S61 *)malloc((unsigned)(Unionoffs(tp, U.V38.texpw) + sizeof(tp->U.V38)));
  356. X        break ;
  357. X      case nempty:
  358. X        tp = (struct S61 *)malloc((unsigned)(Unionoffs(tp, U.V12.tdef)));
  359. X        break ;
  360. X      case nlabstmt:
  361. X        tp = (struct S61 *)malloc((unsigned)(Unionoffs(tp, U.V25.tlabno) + sizeof(tp->U.V25)));
  362. X        break ;
  363. X      case nassign:
  364. X        tp = (struct S61 *)malloc((unsigned)(Unionoffs(tp, U.V27.tlhs) + sizeof(tp->U.V27)));
  365. X        break ;
  366. X      case nformat:
  367. X        tp = (struct S61 *)malloc((unsigned)(Unionoffs(tp, U.V41.texpl) + sizeof(tp->U.V41)));
  368. X        break ;
  369. X      case nin:
  370. X        tp = (struct S61 *)malloc((unsigned)(Unionoffs(tp, U.V41.texpl) + sizeof(tp->U.V41)));
  371. X        break ;
  372. X      case neq:
  373. X        tp = (struct S61 *)malloc((unsigned)(Unionoffs(tp, U.V41.texpl) + sizeof(tp->U.V41)));
  374. X        break ;
  375. X      case nne:
  376. X        tp = (struct S61 *)malloc((unsigned)(Unionoffs(tp, U.V41.texpl) + sizeof(tp->U.V41)));
  377. X        break ;
  378. X      case nlt:
  379. X        tp = (struct S61 *)malloc((unsigned)(Unionoffs(tp, U.V41.texpl) + sizeof(tp->U.V41)));
  380. X        break ;
  381. X      case nle:
  382. X        tp = (struct S61 *)malloc((unsigned)(Unionoffs(tp, U.V41.texpl) + sizeof(tp->U.V41)));
  383. X        break ;
  384. X      case ngt:
  385. X        tp = (struct S61 *)malloc((unsigned)(Unionoffs(tp, U.V41.texpl) + sizeof(tp->U.V41)));
  386. X        break ;
  387. X      case nge:
  388. X        tp = (struct S61 *)malloc((unsigned)(Unionoffs(tp, U.V41.texpl) + sizeof(tp->U.V41)));
  389. X        break ;
  390. X      case nor:
  391. X        tp = (struct S61 *)malloc((unsigned)(Unionoffs(tp, U.V41.texpl) + sizeof(tp->U.V41)));
  392. X        break ;
  393. X      case nplus:
  394. X        tp = (struct S61 *)malloc((unsigned)(Unionoffs(tp, U.V41.texpl) + sizeof(tp->U.V41)));
  395. X        break ;
  396. X      case nminus:
  397. X        tp = (struct S61 *)malloc((unsigned)(Unionoffs(tp, U.V41.texpl) + sizeof(tp->U.V41)));
  398. X        break ;
  399. X      case nand:
  400. X        tp = (struct S61 *)malloc((unsigned)(Unionoffs(tp, U.V41.texpl) + sizeof(tp->U.V41)));
  401. X        break ;
  402. X      case nmul:
  403. X        tp = (struct S61 *)malloc((unsigned)(Unionoffs(tp, U.V41.texpl) + sizeof(tp->U.V41)));
  404. X        break ;
  405. X      case ndiv:
  406. X        tp = (struct S61 *)malloc((unsigned)(Unionoffs(tp, U.V41.texpl) + sizeof(tp->U.V41)));
  407. X        break ;
  408. X      case nmod:
  409. X        tp = (struct S61 *)malloc((unsigned)(Unionoffs(tp, U.V41.texpl) + sizeof(tp->U.V41)));
  410. X        break ;
  411. X      case nquot:
  412. X        tp = (struct S61 *)malloc((unsigned)(Unionoffs(tp, U.V41.texpl) + sizeof(tp->U.V41)));
  413. X        break ;
  414. X      case nnot:
  415. X        tp = (struct S61 *)malloc((unsigned)(Unionoffs(tp, U.V42.texps) + sizeof(tp->U.V42)));
  416. X        break ;
  417. X      case numinus:
  418. X        tp = (struct S61 *)malloc((unsigned)(Unionoffs(tp, U.V42.texps) + sizeof(tp->U.V42)));
  419. X        break ;
  420. X      case nuplus:
  421. X        tp = (struct S61 *)malloc((unsigned)(Unionoffs(tp, U.V42.texps) + sizeof(tp->U.V42)));
  422. X        break ;
  423. X      case nset:
  424. X        tp = (struct S61 *)malloc((unsigned)(Unionoffs(tp, U.V42.texps) + sizeof(tp->U.V42)));
  425. X        break ;
  426. X      case nrange:
  427. X        tp = (struct S61 *)malloc((unsigned)(Unionoffs(tp, U.V41.texpl) + sizeof(tp->U.V41)));
  428. X        break ;
  429. X      case nindex:
  430. X        tp = (struct S61 *)malloc((unsigned)(Unionoffs(tp, U.V39.tvariable) + sizeof(tp->U.V39)));
  431. X        break ;
  432. X      case nselect:
  433. X        tp = (struct S61 *)malloc((unsigned)(Unionoffs(tp, U.V40.trecord) + sizeof(tp->U.V40)));
  434. X        break ;
  435. X      case nderef:
  436. X        tp = (struct S61 *)malloc((unsigned)(Unionoffs(tp, U.V42.texps) + sizeof(tp->U.V42)));
  437. X        break ;
  438. X      case ncall:
  439. X        tp = (struct S61 *)malloc((unsigned)(Unionoffs(tp, U.V30.tcall) + sizeof(tp->U.V30)));
  440. X        break ;
  441. X      case nid:
  442. X        tp = (struct S61 *)malloc((unsigned)(Unionoffs(tp, U.V43.tsym) + sizeof(tp->U.V43)));
  443. X        break ;
  444. X      case nchar:
  445. X        tp = (struct S61 *)malloc((unsigned)(Unionoffs(tp, U.V43.tsym) + sizeof(tp->U.V43)));
  446. X        break ;
  447. X      case ninteger:
  448. X        tp = (struct S61 *)malloc((unsigned)(Unionoffs(tp, U.V43.tsym) + sizeof(tp->U.V43)));
  449. X        break ;
  450. X      case nreal:
  451. X        tp = (struct S61 *)malloc((unsigned)(Unionoffs(tp, U.V43.tsym) + sizeof(tp->U.V43)));
  452. X        break ;
  453. X      case nstring:
  454. X        tp = (struct S61 *)malloc((unsigned)(Unionoffs(tp, U.V43.tsym) + sizeof(tp->U.V43)));
  455. X        break ;
  456. X      case nnil:
  457. X        tp = (struct S61 *)malloc((unsigned)(Unionoffs(tp, U.V12.tdef)));
  458. X        break ;
  459. X      case npush:
  460. X        tp = (struct S61 *)malloc((unsigned)(Unionoffs(tp, U.V28.tglob) + sizeof(tp->U.V28)));
  461. X        break ;
  462. X      case npop:
  463. X        tp = (struct S61 *)malloc((unsigned)(Unionoffs(tp, U.V28.tglob) + sizeof(tp->U.V28)));
  464. X        break ;
  465. X      case nbreak:
  466. X        tp = (struct S61 *)malloc((unsigned)(Unionoffs(tp, U.V29.tbrkid) + sizeof(tp->U.V29)));
  467. X        break ;
  468. X      default:
  469. X        Caseerror(Line);
  470. X    }
  471. X    if (tp == (struct S61 *)NIL)
  472. X        error(enew);
  473. X    tp->tt = nt;
  474. X    tp->tnext = (struct S61 *)NIL;
  475. X    tp->tup = (struct S61 *)NIL;
  476. X    tp->ttype = (struct S61 *)NIL;
  477. X    R94 = tp;
  478. X    return R94;
  479. X}
  480. X
  481. X treeptr
  482. Xmklit()
  483. X{
  484. X    register treeptr    R95;
  485. X    symptr    sp;
  486. X    treeptr    tp;
  487. X
  488. X    switch (currsym.st) {
  489. X      case sinteger:
  490. X        sp = mksym(linteger);
  491. X        sp->U.V10.linum = currsym.U.V3.vint;
  492. X        tp = mknode(ninteger);
  493. X        break ;
  494. X      case sreal:
  495. X        sp = mksym(lreal);
  496. X        sp->U.V8.lfloat = currsym.U.V4.vflt;
  497. X        tp = mknode(nreal);
  498. X        break ;
  499. X      case schar:
  500. X        sp = mksym(lcharacter);
  501. X        sp->U.V11.lchar = currsym.U.V2.vchr;
  502. X        tp = mknode(nchar);
  503. X        break ;
  504. X      case sstring:
  505. X        sp = mksym(lstring);
  506. X        sp->U.V7.lstr = currsym.U.V5.vstr;
  507. X        tp = mknode(nstring);
  508. X        break ;
  509. X      default:
  510. X        Caseerror(Line);
  511. X    }
  512. X    tp->U.V43.tsym = sp;
  513. X    sp->lsymdecl = tp;
  514. X    R95 = tp;
  515. X    return R95;
  516. X}
  517. X
  518. X symptr
  519. Xlookupid(ip, fieldok)
  520. X    idptr    ip;
  521. X    boolean    fieldok;
  522. X{
  523. X    register symptr    R96;
  524. X    symptr    sp;
  525. X    declptr    dp;
  526. X    struct { setword    S[2]; }    vs;
  527. X
  528. X    R96 = (struct S62 *)NIL;
  529. X    if (fieldok)
  530. X        Setncpy(vs.S, Conset[2], sizeof(vs.S));
  531. X    else
  532. X        Setncpy(vs.S, Conset[3], sizeof(vs.S));
  533. X    sp = (struct S62 *)NIL;
  534. X    dp = symtab;
  535. X    while (dp != (struct S60 *)NIL) {
  536. X        sp = dp->ddecl.A[ip->ihash];
  537. X        while (sp != (struct S62 *)NIL) {
  538. X            if ((Member((unsigned)(sp->lt), vs.S)) && (sp->U.V6.lid == ip))
  539. X                goto L999;
  540. X            sp = sp->lnext;
  541. X        }
  542. X        dp = dp->dprev;
  543. X    }
  544. XL999:
  545. X    R96 = sp;
  546. X    return R96;
  547. X}
  548. X
  549. X symptr
  550. Xlookuplabel(i)
  551. X    integer    i;
  552. X{
  553. X    register symptr    R97;
  554. X    symptr    sp;
  555. X    declptr    dp;
  556. X
  557. X    sp = (struct S62 *)NIL;
  558. X    dp = symtab;
  559. X    while (dp != (struct S60 *)NIL) {
  560. X        sp = dp->ddecl.A[hashmax];
  561. X        while (sp != (struct S62 *)NIL) {
  562. X            if ((Member((unsigned)(sp->lt), Conset[4])) && (sp->U.V9.lno == i))
  563. X                goto L999;
  564. X            sp = sp->lnext;
  565. X        }
  566. X        dp = dp->dprev;
  567. X    }
  568. XL999:
  569. X    R97 = sp;
  570. X    return R97;
  571. X}
  572. X
  573. X void
  574. Xenterscope(dp)
  575. X    declptr    dp;
  576. X{
  577. X    register hashtyp    h;
  578. X
  579. X    if (dp == (struct S60 *)NIL) {
  580. X        dp = (struct S60 *)malloc((unsigned)(sizeof(*dp)));
  581. X        {
  582. X            hashtyp    B47 = 0,
  583. X                B48 = hashmax;
  584. X
  585. X            if (B47 <= B48)
  586. X                for (h = B47; ; h++) {
  587. X                    dp->ddecl.A[h] = (struct S62 *)NIL;
  588. X                    if (h == B48) break;
  589. X                }
  590. X        }
  591. X    }
  592. X    dp->dprev = symtab;
  593. X    symtab = dp;
  594. X}
  595. X
  596. X declptr
  597. Xcurrscope()
  598. X{
  599. X    register declptr    R98;
  600. X
  601. X    R98 = symtab;
  602. X    return R98;
  603. X}
  604. X
  605. X void
  606. Xleavescope()
  607. X{
  608. X    symtab = symtab->dprev;
  609. X}
  610. X
  611. X symptr
  612. Xmkid(ip)
  613. X    idptr    ip;
  614. X{
  615. X    register symptr    R99;
  616. X    symptr    sp;
  617. X
  618. X    sp = mksym(lidentifier);
  619. X    sp->U.V6.lid = ip;
  620. X    sp->U.V6.lused = false;
  621. X    declsym(sp);
  622. X    ip->inref = ip->inref + 1;
  623. X    R99 = sp;
  624. X    return R99;
  625. X}
  626. X
  627. X treeptr
  628. Xnewid(ip)
  629. X    idptr    ip;
  630. X{
  631. X    register treeptr    R100;
  632. X    symptr    sp;
  633. X    treeptr    tp;
  634. X
  635. X    sp = lookupid(ip, false);
  636. X    if (sp != (struct S62 *)NIL)
  637. X        if (sp->ldecl != symtab)
  638. X            sp = (struct S62 *)NIL;
  639. X    if (sp == (struct S62 *)NIL) {
  640. X        tp = mknode(nid);
  641. X        sp = mkid(ip);
  642. X        sp->lsymdecl = tp;
  643. X        tp->U.V43.tsym = sp;
  644. X    } else
  645. X        if (sp->lt == lpointer) {
  646. X            tp = mknode(nid);
  647. X            tp->U.V43.tsym = sp;
  648. X            sp->lt = lidentifier;
  649. X            sp->lsymdecl = tp;
  650. X        } else
  651. X            if (sp->lt == lforward) {
  652. X                sp->lt = lidentifier;
  653. X                tp = sp->lsymdecl;
  654. X            } else
  655. X                error(emultdeclid);
  656. X    R100 = tp;
  657. X    return R100;
  658. X}
  659. X
  660. X treeptr
  661. Xoldid(ip, l)
  662. X    idptr    ip;
  663. X    ltypes    l;
  664. X{
  665. X    register treeptr    R101;
  666. X    symptr    sp;
  667. X    treeptr    tp;
  668. X
  669. X    sp = lookupid(ip, true);
  670. X    if (sp == (struct S62 *)NIL) {
  671. X        if (Member((unsigned)(l), Conset[5])) {
  672. X            tp = newid(ip);
  673. X            tp->U.V43.tsym->lt = l;
  674. X        } else
  675. X            error(enotdeclid);
  676. X    } else {
  677. X        sp->U.V6.lused = true;
  678. X        tp = mknode(nid);
  679. X        tp->U.V43.tsym = sp;
  680. X        if ((sp->lt == lpointer) && (l == lidentifier)) {
  681. X            sp->lt = lidentifier;
  682. X            sp->lsymdecl = tp;
  683. X        }
  684. X    }
  685. X    R101 = tp;
  686. X    return R101;
  687. X}
  688. X
  689. X treeptr
  690. Xoldfield(tp, ip)
  691. X    treeptr    tp;
  692. X    idptr    ip;
  693. X{
  694. X    register treeptr    R102;
  695. X    treeptr    tq, ti, fp;
  696. X
  697. X    fp = (struct S61 *)NIL;
  698. X    tq = tp->U.V21.tflist;
  699. X    while (tq != (struct S61 *)NIL) {
  700. X        ti = tq->U.V14.tidl;
  701. X        while (ti != (struct S61 *)NIL) {
  702. X            if (ti->U.V43.tsym->U.V6.lid == ip) {
  703. X                fp = mknode(nid);
  704. X                fp->U.V43.tsym = ti->U.V43.tsym;
  705. X                goto L999;
  706. X            }
  707. X            ti = ti->tnext;
  708. X        }
  709. X        tq = tq->tnext;
  710. X    }
  711. X    tq = tp->U.V21.tvlist;
  712. X    while (tq != (struct S61 *)NIL) {
  713. X        fp = oldfield(tq->U.V20.tvrnt, ip);
  714. X        if (fp != (struct S61 *)NIL)
  715. X            tq = (struct S61 *)NIL;
  716. X        else
  717. X            tq = tq->tnext;
  718. X    }
  719. XL999:
  720. X    R102 = fp;
  721. X    return R102;
  722. X}
  723. X
  724. Xvoid parse();
  725. X
  726. Xtreeptr plabel();
  727. X
  728. Xtreeptr pidlist();
  729. X
  730. X
  731. Xtreeptr pconst();
  732. X
  733. Xtreeptr pconstant();
  734. X
  735. Xtreeptr precord();
  736. X
  737. Xtreeptr ptypedef();
  738. X
  739. Xtreeptr ptype();
  740. X
  741. Xtreeptr pvar();
  742. X
  743. Xtreeptr psubs();
  744. X
  745. Xtreeptr psubpar();
  746. X
  747. Xtreeptr plabstmt();
  748. X
  749. Xtreeptr pstmt();
  750. X
  751. Xtreeptr psimple();
  752. X
  753. Xtreeptr pvariable();
  754. X
  755. Xtreeptr pexpr();
  756. X
  757. Xtreeptr pcase();
  758. X
  759. Xtreeptr pif();
  760. X
  761. Xtreeptr pwhile();
  762. X
  763. Xtreeptr prepeat();
  764. X
  765. Xtreeptr pfor();
  766. X
  767. Xtreeptr pwith();
  768. X
  769. Xtreeptr pgoto();
  770. X
  771. Xtreeptr pbegin();
  772. X
  773. Xvoid scopeup();
  774. X
  775. X void
  776. Xaddfields(rp)
  777. X    treeptr    rp;
  778. X{
  779. X    treeptr    fp, ip, vp;
  780. X    symptr    sp;
  781. X
  782. X    fp = rp->U.V21.tflist;
  783. X    while (fp != (struct S61 *)NIL) {
  784. X        ip = fp->U.V14.tidl;
  785. X        while (ip != (struct S61 *)NIL) {
  786. X            sp = mksym(lfield);
  787. X            sp->U.V6.lid = ip->U.V43.tsym->U.V6.lid;
  788. X            sp->U.V6.lused = false;
  789. X            sp->lsymdecl = ip;
  790. X            declsym(sp);
  791. X            ip = ip->tnext;
  792. X        }
  793. X        fp = fp->tnext;
  794. X    }
  795. X    vp = rp->U.V21.tvlist;
  796. X    while (vp != (struct S61 *)NIL) {
  797. X        addfields(vp->U.V20.tvrnt);
  798. X        vp = vp->tnext;
  799. X    }
  800. X}
  801. X
  802. X void
  803. Xscopeup(tp)
  804. X    treeptr    tp;
  805. X{
  806. X    addfields(typeof(tp));
  807. X}
  808. X
  809. X treeptr
  810. Xnewlbl()
  811. X{
  812. X    register treeptr    R126;
  813. X    symptr    sp;
  814. X    treeptr    tp;
  815. X
  816. X    tp = mknode(nlabel);
  817. X    sp = lookuplabel(currsym.U.V3.vint);
  818. X    if (sp != (struct S62 *)NIL)
  819. X        if (sp->ldecl != symtab)
  820. X            sp = (struct S62 *)NIL;
  821. X    if (sp == (struct S62 *)NIL) {
  822. X        sp = mksym(lforwlab);
  823. X        sp->U.V9.lno = currsym.U.V3.vint;
  824. X        sp->U.V9.lgo = false;
  825. X        sp->lsymdecl = tp;
  826. X        declsym(sp);
  827. X    } else
  828. X        error(emultdecllab);
  829. X    tp->U.V43.tsym = sp;
  830. X    R126 = tp;
  831. X    return R126;
  832. X}
  833. X
  834. X treeptr
  835. Xoldlbl(defpt)
  836. X    boolean    defpt;
  837. X{
  838. X    register treeptr    R127;
  839. X    symptr    sp;
  840. X    treeptr    tp;
  841. X
  842. X    sp = lookuplabel(currsym.U.V3.vint);
  843. X    if (sp == (struct S62 *)NIL) {
  844. X        prtmsg(enotdecllab);
  845. X        tp = newlbl();
  846. X        sp = tp->U.V43.tsym;
  847. X    } else {
  848. X        tp = mknode(nlabel);
  849. X        tp->U.V43.tsym = sp;
  850. X    }
  851. X    if (defpt) {
  852. X        if (sp->lt == lforwlab)
  853. X            sp->lt = llabel;
  854. X        else
  855. X            error(emuldeflab);
  856. X    }
  857. X    R127 = tp;
  858. X    return R127;
  859. X}
  860. X
  861. X void
  862. Xpbody(tp)
  863. X    treeptr    tp;
  864. X{
  865. X    treeptr    tq;
  866. X
  867. X    statlvl = statlvl + 1;
  868. X    if (currsym.st == slabel) {
  869. X        tp->U.V13.tsublab = plabel();
  870. X        linkup(tp, tp->U.V13.tsublab);
  871. X    } else
  872. X        tp->U.V13.tsublab = (struct S61 *)NIL;
  873. X    if (currsym.st == sconst) {
  874. X        tp->U.V13.tsubconst = pconst();
  875. X        linkup(tp, tp->U.V13.tsubconst);
  876. X    } else
  877. X        tp->U.V13.tsubconst = (struct S61 *)NIL;
  878. X    if (currsym.st == stype) {
  879. X        tp->U.V13.tsubtype = ptype();
  880. X        linkup(tp, tp->U.V13.tsubtype);
  881. X    } else
  882. X        tp->U.V13.tsubtype = (struct S61 *)NIL;
  883. X    if (currsym.st == svar) {
  884. X        tp->U.V13.tsubvar = pvar();
  885. X        linkup(tp, tp->U.V13.tsubvar);
  886. X    } else
  887. X        tp->U.V13.tsubvar = (struct S61 *)NIL;
  888. X    tp->U.V13.tsubsub = (struct S61 *)NIL;
  889. X    tq = (struct S61 *)NIL;
  890. X    while ((currsym.st == sproc) || (currsym.st == sfunc)) {
  891. X        if (tq == (struct S61 *)NIL) {
  892. X            tq = psubs();
  893. X            tp->U.V13.tsubsub = tq;
  894. X        } else {
  895. X            tq->tnext = psubs();
  896. X            tq = tq->tnext;
  897. X        }
  898. X    }
  899. X    linkup(tp, tp->U.V13.tsubsub);
  900. X    checksymbol(*((symset *)Conset[6]));
  901. X    if (currsym.st == sbegin) {
  902. X        tp->U.V13.tsubstmt = pbegin(false);
  903. X        linkup(tp, tp->U.V13.tsubstmt);
  904. X    }
  905. X    statlvl = statlvl - 1;
  906. X}
  907. X
  908. Xtreeptr pprogram();
  909. X
  910. X treeptr
  911. Xpprmlist()
  912. X{
  913. X    register treeptr    R129;
  914. X    treeptr    tp, tq;
  915. X    idptr    din, dut;
  916. X
  917. X    tp = (struct S61 *)NIL;
  918. X    din = deftab.A[(int)(dinput)]->U.V14.tidl->U.V43.tsym->U.V6.lid;
  919. X    dut = deftab.A[(int)(doutput)]->U.V14.tidl->U.V43.tsym->U.V6.lid;
  920. X    while ((currsym.U.V1.vid == din) || (currsym.U.V1.vid == dut)) {
  921. X        if (currsym.U.V1.vid == din)
  922. X            defnams.A[(int)(dinput)]->U.V6.lused = true;
  923. X        else
  924. X            defnams.A[(int)(doutput)]->U.V6.lused = true;
  925. X        nextsymbol(*((symset *)Conset[7]));
  926. X        if (currsym.st == srpar)
  927. X            goto L999;
  928. X        nextsymbol(*((symset *)Conset[8]));
  929. X    }
  930. X    tq = newid(currsym.U.V1.vid);
  931. X    tq->U.V43.tsym->lt = lpointer;
  932. X    tp = tq;
  933. X    nextsymbol(*((symset *)Conset[9]));
  934. X    while (currsym.st == scomma) {
  935. X        nextsymbol(*((symset *)Conset[10]));
  936. X        if (currsym.U.V1.vid == din)
  937. X            defnams.A[(int)(dinput)]->U.V6.lused = true;
  938. X        else
  939. X            if (currsym.U.V1.vid == dut)
  940. X                defnams.A[(int)(doutput)]->U.V6.lused = true;
  941. X            else {
  942. X                tq->tnext = newid(currsym.U.V1.vid);
  943. X                tq = tq->tnext;
  944. X                tq->U.V43.tsym->lt = lpointer;
  945. X            }
  946. X        nextsymbol(*((symset *)Conset[11]));
  947. X    }
  948. XL999:
  949. X    R129 = tp;
  950. X    return R129;
  951. X}
  952. X
  953. X treeptr
  954. Xpprogram()
  955. X{
  956. X    register treeptr    R128;
  957. X    treeptr    tp;
  958. X
  959. X    enterscope((declptr)NIL);
  960. X    tp = mknode(npgm);
  961. X    nextsymbol(*((symset *)Conset[12]));
  962. X    tp->U.V13.tstat = statlvl;
  963. X    tp->U.V13.tsubid = mknode(nid);
  964. X    tp->U.V13.tsubid->tup = tp;
  965. X    tp->U.V13.tsubid->U.V43.tsym = mksym(lidentifier);
  966. X    tp->U.V13.tsubid->U.V43.tsym->U.V6.lid = currsym.U.V1.vid;
  967. X    tp->U.V13.tsubid->U.V43.tsym->lsymdecl = tp->U.V13.tsubid;
  968. X    linkup(tp, tp->U.V13.tsubid);
  969. X    nextsymbol(*((symset *)Conset[13]));
  970. X    if (currsym.st == slpar) {
  971. X        nextsymbol(*((symset *)Conset[14]));
  972. X        tp->U.V13.tsubpar = pprmlist();
  973. X        linkup(tp, tp->U.V13.tsubpar);
  974. X        nextsymbol(*((symset *)Conset[15]));
  975. X    } else
  976. X        tp->U.V13.tsubpar = (struct S61 *)NIL;
  977. X    nextsymbol(*((symset *)Conset[16]));
  978. X    pbody(tp);
  979. X    checksymbol(*((symset *)Conset[17]));
  980. X    tp->U.V13.tscope = currscope();
  981. X    leavescope();
  982. X    R128 = tp;
  983. X    return R128;
  984. X}
  985. X
  986. X treeptr
  987. Xpmodule()
  988. X{
  989. X    register treeptr    R130;
  990. X    treeptr    tp;
  991. X
  992. X    enterscope((declptr)NIL);
  993. X    tp = mknode(npgm);
  994. X    tp->U.V13.tstat = statlvl;
  995. X    tp->U.V13.tsubid = (struct S61 *)NIL;
  996. X    tp->U.V13.tsubpar = (struct S61 *)NIL;
  997. X    pbody(tp);
  998. X    checksymbol(*((symset *)Conset[18]));
  999. X    tp->U.V13.tscope = currscope();
  1000. X    leavescope();
  1001. X    R130 = tp;
  1002. X    return R130;
  1003. X}
  1004. X
  1005. X treeptr
  1006. Xplabel()
  1007. X{
  1008. X    register treeptr    R131;
  1009. X    treeptr    tp, tq;
  1010. X
  1011. X    tq = (struct S61 *)NIL;
  1012. X    do {
  1013. X        nextsymbol(*((symset *)Conset[19]));
  1014. X        if (tq == (struct S61 *)NIL) {
  1015. X            tq = newlbl();
  1016. X            tp = tq;
  1017. X        } else {
  1018. X            tq->tnext = newlbl();
  1019. X            tq = tq->tnext;
  1020. X        }
  1021. X        nextsymbol(*((symset *)Conset[20]));
  1022. X    } while (!(currsym.st == ssemic));
  1023. X    nextsymbol(*((symset *)Conset[21]));
  1024. X    R131 = tp;
  1025. X    return R131;
  1026. X}
  1027. X
  1028. X treeptr
  1029. Xpidlist(l)
  1030. X    ltypes    l;
  1031. X{
  1032. X    register treeptr    R132;
  1033. X    treeptr    tp, tq;
  1034. X
  1035. X    tq = newid(currsym.U.V1.vid);
  1036. X    tq->U.V43.tsym->lt = l;
  1037. X    tp = tq;
  1038. X    nextsymbol(*((symset *)Conset[22]));
  1039. X    while (currsym.st == scomma) {
  1040. X        nextsymbol(*((symset *)Conset[23]));
  1041. X        tq->tnext = newid(currsym.U.V1.vid);
  1042. X        tq = tq->tnext;
  1043. X        tq->U.V43.tsym->lt = l;
  1044. X        nextsymbol(*((symset *)Conset[24]));
  1045. X    }
  1046. X    R132 = tp;
  1047. X    return R132;
  1048. X}
  1049. X
  1050. X treeptr
  1051. Xpconst()
  1052. X{
  1053. X    register treeptr    R133;
  1054. X    treeptr    tp, tq;
  1055. X
  1056. X    tq = (struct S61 *)NIL;
  1057. X    nextsymbol(*((symset *)Conset[25]));
  1058. X    do {
  1059. X        if (tq == (struct S61 *)NIL) {
  1060. X            tq = mknode(nconst);
  1061. X            tq->U.V14.tattr = anone;
  1062. X            tp = tq;
  1063. X        } else {
  1064. X            tq->tnext = mknode(nconst);
  1065. X            tq = tq->tnext;
  1066. X            tq->U.V14.tattr = anone;
  1067. X        }
  1068. X        tq->U.V14.tidl = pidlist(lidentifier);
  1069. X        checksymbol(*((symset *)Conset[26]));
  1070. X        nextsymbol(*((symset *)Conset[27]));
  1071. X        tq->U.V14.tbind = pconstant(true);
  1072. X        nextsymbol(*((symset *)Conset[28]));
  1073. X        nextsymbol(*((symset *)Conset[29]));
  1074. X    } while (!(currsym.st != sid));
  1075. X    R133 = tp;
  1076. X    return R133;
  1077. X}
  1078. X
  1079. X treeptr
  1080. Xpconstant(realok)
  1081. X    boolean    realok;
  1082. X{
  1083. X    register treeptr    R134;
  1084. X    treeptr    tp, tq;
  1085. X    boolean    neg;
  1086. X
  1087. X    neg = (boolean)(currsym.st == sminus);
  1088. X    if (Member((unsigned)(currsym.st), Conset[30]))
  1089. X        if (realok)
  1090. X            nextsymbol(*((symset *)Conset[31]));
  1091. X        else
  1092. X            nextsymbol(*((symset *)Conset[32]));
  1093. X    if (currsym.st == sid)
  1094. X        tp = oldid(currsym.U.V1.vid, lidentifier);
  1095. X    else
  1096. X        tp = mklit();
  1097. X    if (neg) {
  1098. X        tq = mknode(numinus);
  1099. X        tq->U.V42.texps = tp;
  1100. X        tp = tq;
  1101. X    }
  1102. X    R134 = tp;
  1103. X    return R134;
  1104. X}
  1105. X
  1106. X treeptr
  1107. Xprecord(cs, dp)
  1108. X    symtyp    cs;
  1109. X    declptr    dp;
  1110. X{
  1111. X    register treeptr    R135;
  1112. X    treeptr    tp, tq, tl, tv;
  1113. X    lexsym    tsym;
  1114. X
  1115. X    tp = mknode(nrecord);
  1116. X    tp->U.V21.tflist = (struct S61 *)NIL;
  1117. X    tp->U.V21.tvlist = (struct S61 *)NIL;
  1118. X    tp->U.V21.tuid = (struct S59 *)NIL;
  1119. X    tp->U.V21.trscope = (struct S60 *)NIL;
  1120. X    if (cs == send) {
  1121. X        enterscope(dp);
  1122. X        dp = currscope();
  1123. X    }
  1124. X    nextsymbol(*((symset *)Union(Conset[33], Saveset((Tmpset = Newset(), (void)Insmem((unsigned)(cs), Tmpset), Tmpset)))));
  1125. X    Claimset();
  1126. X    tq = (struct S61 *)NIL;
  1127. X    while (currsym.st == sid) {
  1128. X        if (tq == (struct S61 *)NIL) {
  1129. X            tq = mknode(nfield);
  1130. X            tq->U.V14.tattr = anone;
  1131. X            tp->U.V21.tflist = tq;
  1132. X        } else {
  1133. X            tq->tnext = mknode(nfield);
  1134. X            tq = tq->tnext;
  1135. X            tq->U.V14.tattr = anone;
  1136. X        }
  1137. X        tq->U.V14.tidl = pidlist(lfield);
  1138. X        checksymbol(*((symset *)Conset[34]));
  1139. X        leavescope();
  1140. X        tq->U.V14.tbind = ptypedef();
  1141. X        enterscope(dp);
  1142. X        if (currsym.st == ssemic)
  1143. X            nextsymbol(*((symset *)Union(Conset[35], Saveset((Tmpset = Newset(), (void)Insmem((unsigned)(cs), Tmpset), Tmpset)))));
  1144. X        Claimset();
  1145. X    }
  1146. X    if (currsym.st == scase) {
  1147. X        nextsymbol(*((symset *)Conset[36]));
  1148. X        tsym = currsym;
  1149. X        nextsymbol(*((symset *)Conset[37]));
  1150. X        if (currsym.st == scolon) {
  1151. X            tv = newid(tsym.U.V1.vid);
  1152. X            if (tq == (struct S61 *)NIL) {
  1153. X                tq = mknode(nfield);
  1154. X                tp->U.V21.tflist = tq;
  1155. X            } else {
  1156. X                tq->tnext = mknode(nfield);
  1157. X                tq = tq->tnext;
  1158. X            }
  1159. X            tq->U.V14.tidl = tv;
  1160. X            tv->U.V43.tsym->lt = lfield;
  1161. X            nextsymbol(*((symset *)Conset[38]));
  1162. X            leavescope();
  1163. X            tq->U.V14.tbind = oldid(currsym.U.V1.vid, lidentifier);
  1164. X            enterscope(dp);
  1165. X            nextsymbol(*((symset *)Conset[39]));
  1166. X        }
  1167. X        tq = (struct S61 *)NIL;
  1168. X        do {
  1169. X            tv = (struct S61 *)NIL;
  1170. X            do {
  1171. X                nextsymbol(*((symset *)Union(Conset[40], Saveset((Tmpset = Newset(), (void)Insmem((unsigned)(cs), Tmpset), Tmpset)))));
  1172. X                Claimset();
  1173. X                if (currsym.st == cs)
  1174. X                    goto L999;
  1175. X                if (tv == (struct S61 *)NIL) {
  1176. X                    tv = pconstant(false);
  1177. X                    tl = tv;
  1178. X                } else {
  1179. X                    tv->tnext = pconstant(false);
  1180. X                    tv = tv->tnext;
  1181. X                }
  1182. X                nextsymbol(*((symset *)Conset[41]));
  1183. X            } while (!(currsym.st == scolon));
  1184. X            nextsymbol(*((symset *)Conset[42]));
  1185. X            if (tq == (struct S61 *)NIL) {
  1186. X                tq = mknode(nvariant);
  1187. X                tp->U.V21.tvlist = tq;
  1188. X            } else {
  1189. X                tq->tnext = mknode(nvariant);
  1190. X                tq = tq->tnext;
  1191. X            }
  1192. X            tq->U.V20.tselct = tl;
  1193. X            tq->U.V20.tvrnt = precord(srpar, dp);
  1194. X        } while (!(currsym.st == cs));
  1195. X    }
  1196. XL999:
  1197. X    if (cs == send) {
  1198. X        tp->U.V21.trscope = dp;
  1199. X        leavescope();
  1200. X    }
  1201. X    nextsymbol(*((symset *)Conset[43]));
  1202. X    R135 = tp;
  1203. X    return R135;
  1204. X}
  1205. X
  1206. X treeptr
  1207. Xptypedef()
  1208. X{
  1209. X    register treeptr    R136;
  1210. X    treeptr    tp, tq;
  1211. X    symtyp    st;
  1212. X    symset    ss;
  1213. X
  1214. X    nextsymbol(*((symset *)Conset[44]));
  1215. X    if (currsym.st == spacked)
  1216. X        nextsymbol(*((symset *)Conset[45]));
  1217. X    Setncpy(ss.S, Conset[46], sizeof(ss.S));
  1218. X    switch (currsym.st) {
  1219. X      case splus:  case sminus:  case schar:  case sinteger:
  1220. X      case sid:
  1221. X        st = currsym.st;
  1222. X        tp = pconstant(false);
  1223. X        if (st == sid)
  1224. X            nextsymbol(*((symset *)Union(Conset[47], ss.S)));
  1225. X        else
  1226. X            nextsymbol(*((symset *)Conset[48]));
  1227. X        Claimset();
  1228. X        if (currsym.st == sdotdot) {
  1229. X            nextsymbol(*((symset *)Conset[49]));
  1230. X            tq = mknode(nsubrange);
  1231. X            tq->U.V19.tlo = tp;
  1232. X            tq->U.V19.thi = pconstant(false);
  1233. X            tp = tq;
  1234. X            nextsymbol(ss);
  1235. X        }
  1236. X        break ;
  1237. X      case slpar:
  1238. X        tp = mknode(nscalar);
  1239. X        nextsymbol(*((symset *)Conset[50]));
  1240. X        tp->U.V17.tscalid = pidlist(lidentifier);
  1241. X        checksymbol(*((symset *)Conset[51]));
  1242. X        nextsymbol(ss);
  1243. X        break ;
  1244. X      case sarrow:
  1245. X        tp = mknode(nptr);
  1246. X        nextsymbol(*((symset *)Conset[52]));
  1247. X        tp->U.V16.tptrid = oldid(currsym.U.V1.vid, lpointer);
  1248. X        tp->U.V16.tptrflag = false;
  1249. X        nextsymbol(*((symset *)Conset[53]));
  1250. X        break ;
  1251. X      case sarray:
  1252. X        nextsymbol(*((symset *)Conset[54]));
  1253. X        tp = mknode(narray);
  1254. X        tp->U.V23.taindx = ptypedef();
  1255. X        tq = tp;
  1256. X        while (currsym.st == scomma) {
  1257. X            tq->U.V23.taelem = mknode(narray);
  1258. X            tq = tq->U.V23.taelem;
  1259. X            tq->U.V23.taindx = ptypedef();
  1260. X        }
  1261. X        checksymbol(*((symset *)Conset[55]));
  1262. X        nextsymbol(*((symset *)Conset[56]));
  1263. X        tq->U.V23.taelem = ptypedef();
  1264. X        break ;
  1265. X      case srecord:
  1266. X        tp = precord(send, (declptr)NIL);
  1267. X        break ;
  1268. X      case sfile:  case sset:
  1269. X        if (currsym.st == sfile)
  1270. X            tp = mknode(nfileof);
  1271. X        else {
  1272. X            tp = mknode(nsetof);
  1273. X            usesets = true;
  1274. X        }
  1275. X        nextsymbol(*((symset *)Conset[57]));
  1276. X        tp->U.V18.tof = ptypedef();
  1277. X        break ;
  1278. X      default:
  1279. X        Caseerror(Line);
  1280. X    }
  1281. X    R136 = tp;
  1282. X    return R136;
  1283. X}
  1284. X
  1285. X treeptr
  1286. Xptype()
  1287. X{
  1288. X    register treeptr    R137;
  1289. X    treeptr    tp, tq;
  1290. X
  1291. X    tq = (struct S61 *)NIL;
  1292. X    nextsymbol(*((symset *)Conset[58]));
  1293. X    do {
  1294. X        if (tq == (struct S61 *)NIL) {
  1295. X            tq = mknode(ntype);
  1296. X            tq->U.V14.tattr = anone;
  1297. X            tp = tq;
  1298. X        } else {
  1299. X            tq->tnext = mknode(ntype);
  1300. X            tq = tq->tnext;
  1301. X            tq->U.V14.tattr = anone;
  1302. X        }
  1303. X        tq->U.V14.tidl = pidlist(lidentifier);
  1304. X        checksymbol(*((symset *)Conset[59]));
  1305. X        tq->U.V14.tbind = ptypedef();
  1306. X        nextsymbol(*((symset *)Conset[60]));
  1307. X    } while (!(currsym.st != sid));
  1308. X    R137 = tp;
  1309. X    return R137;
  1310. X}
  1311. X
  1312. X treeptr
  1313. Xpvar()
  1314. X{
  1315. X    register treeptr    R138;
  1316. X    treeptr    ti, tp, tq;
  1317. X
  1318. X    tq = (struct S61 *)NIL;
  1319. X    nextsymbol(*((symset *)Conset[61]));
  1320. X    do {
  1321. X        if (tq == (struct S61 *)NIL) {
  1322. X            tq = mknode(nvar);
  1323. X            tq->U.V14.tattr = anone;
  1324. X            tp = tq;
  1325. X        } else {
  1326. X            tq->tnext = mknode(nvar);
  1327. X            tq = tq->tnext;
  1328. X            tq->U.V14.tattr = anone;
  1329. X        }
  1330. X        ti = newid(currsym.U.V1.vid);
  1331. X        tq->U.V14.tidl = ti;
  1332. X        nextsymbol(*((symset *)Conset[62]));
  1333. X        while (currsym.st == scomma) {
  1334. X            nextsymbol(*((symset *)Conset[63]));
  1335. X            ti->tnext = newid(currsym.U.V1.vid);
  1336. X            ti = ti->tnext;
  1337. X            nextsymbol(*((symset *)Conset[64]));
  1338. X        }
  1339. X        tq->U.V14.tbind = ptypedef();
  1340. X        nextsymbol(*((symset *)Conset[65]));
  1341. X    } while (!(currsym.st != sid));
  1342. X    R138 = tp;
  1343. X    return R138;
  1344. X}
  1345. X
  1346. X treeptr
  1347. Xpsubs()
  1348. X{
  1349. X    register treeptr    R139;
  1350. X    treeptr    tp, tv, tq;
  1351. X    boolean    func;
  1352. X    symtyp    colsem;
  1353. X
  1354. X    func = (boolean)(currsym.st == sfunc);
  1355. X    if (func)
  1356. X        colsem = scolon;
  1357. X    else
  1358. X        colsem = ssemic;
  1359. X    nextsymbol(*((symset *)Conset[66]));
  1360. X    tq = newid(currsym.U.V1.vid);
  1361. X    if (tq->tup == (struct S61 *)NIL) {
  1362. X        enterscope((declptr)NIL);
  1363. X        if (func)
  1364. X            tp = mknode(nfunc);
  1365. X        else
  1366. X            tp = mknode(nproc);
  1367. X        tp->U.V13.tstat = statlvl;
  1368. X        tp->U.V13.tsubid = tq;
  1369. X        linkup(tp, tq);
  1370. X        nextsymbol(*((symset *)(Tmpset = Newset(), (void)Insmem((unsigned)(slpar), Tmpset),
  1371. X            (void)Insmem((unsigned)(colsem), Tmpset), Tmpset)));
  1372. X        if (currsym.st == slpar) {
  1373. X            tp->U.V13.tsubpar = psubpar();
  1374. X            linkup(tp, tp->U.V13.tsubpar);
  1375. X            nextsymbol(*((symset *)(Tmpset = Newset(), (void)Insmem((unsigned)(colsem), Tmpset), Tmpset)));
  1376. X        } else
  1377. X            tp->U.V13.tsubpar = (struct S61 *)NIL;
  1378. X        if (func) {
  1379. X            nextsymbol(*((symset *)Conset[67]));
  1380. X            tp->U.V13.tfuntyp = oldid(currsym.U.V1.vid, lidentifier);
  1381. X            nextsymbol(*((symset *)Conset[68]));
  1382. X        } else
  1383. X            tp->U.V13.tfuntyp = mknode(nempty);
  1384. X        linkup(tp, tp->U.V13.tfuntyp);
  1385. X        nextsymbol(*((symset *)Conset[69]));
  1386. X    } else {
  1387. X        enterscope(tq->tup->U.V13.tscope);
  1388. X        if (func)
  1389. X            tp = mknode(nfunc);
  1390. X        else
  1391. X            tp = mknode(nproc);
  1392. X        tp->U.V13.tfuntyp = tq->tup->U.V13.tfuntyp;
  1393. X        tv = tq->tup->U.V13.tsubpar;
  1394. X        tp->U.V13.tsubpar = tv;
  1395. X        while (tv != (struct S61 *)NIL) {
  1396. X            tv->tup = tp;
  1397. X            tv = tv->tnext;
  1398. X        }
  1399. X        tp->U.V13.tsubid = tq;
  1400. X        tq->tup = tp;
  1401. X        nextsymbol(*((symset *)Conset[70]));
  1402. X        nextsymbol(*((symset *)Conset[71]));
  1403. X    }
  1404. X    if (Member((unsigned)(currsym.st), Conset[72])) {
  1405. X        tp->U.V13.tsubid->U.V43.tsym->lt = lforward;
  1406. X        nextsymbol(*((symset *)Conset[73]));
  1407. X        tp->U.V13.tsublab = (struct S61 *)NIL;
  1408. X        tp->U.V13.tsubconst = (struct S61 *)NIL;
  1409. X        tp->U.V13.tsubtype = (struct S61 *)NIL;
  1410. X        tp->U.V13.tsubvar = (struct S61 *)NIL;
  1411. X        tp->U.V13.tsubsub = (struct S61 *)NIL;
  1412. X        tp->U.V13.tsubstmt = (struct S61 *)NIL;
  1413. X    } else
  1414. X        pbody(tp);
  1415. X    nextsymbol(*((symset *)Conset[74]));
  1416. X    tp->U.V13.tscope = currscope();
  1417. X    leavescope();
  1418. X    R139 = tp;
  1419. X    return R139;
  1420. X}
  1421. X
  1422. X treeptr
  1423. Xpconfsub()
  1424. X{
  1425. X    register treeptr    R140;
  1426. X    treeptr    tp;
  1427. X
  1428. X    tp = mknode(nsubrange);
  1429. X    nextsymbol(*((symset *)Conset[75]));
  1430. X    tp->U.V19.tlo = newid(currsym.U.V1.vid);
  1431. X    nextsymbol(*((symset *)Conset[76]));
  1432. X    nextsymbol(*((symset *)Conset[77]));
  1433. X    tp->U.V19.thi = newid(currsym.U.V1.vid);
  1434. X    nextsymbol(*((symset *)Conset[78]));
  1435. X    R140 = tp;
  1436. X    return R140;
  1437. X}
  1438. X
  1439. X treeptr
  1440. Xpconform()
  1441. X{
  1442. X    register treeptr    R141;
  1443. X    treeptr    tp, tq;
  1444. X
  1445. X    nextsymbol(*((symset *)Conset[79]));
  1446. X    tp = mknode(nconfarr);
  1447. X    tp->U.V22.tcuid = mkvariable('S');
  1448. X    tp->U.V22.tcindx = pconfsub();
  1449. X    nextsymbol(*((symset *)Conset[80]));
  1450. X    tp->U.V22.tindtyp = oldid(currsym.U.V1.vid, lidentifier);
  1451. X    nextsymbol(*((symset *)Conset[81]));
  1452. X    tq = tp;
  1453. X    while (currsym.st == ssemic) {
  1454. X        error(econfconf);
  1455. X        tq->U.V22.tcelem = mknode(nconfarr);
  1456. X        tq = tq->U.V22.tcelem;
  1457. X        tq->U.V22.tcindx = pconfsub();
  1458. X        nextsymbol(*((symset *)Conset[82]));
  1459. X        tq->U.V22.tindtyp = oldid(currsym.U.V1.vid, lidentifier);
  1460. X        nextsymbol(*((symset *)Conset[83]));
  1461. X    }
  1462. X    nextsymbol(*((symset *)Conset[84]));
  1463. X    nextsymbol(*((symset *)Conset[85]));
  1464. X    switch (currsym.st) {
  1465. X      case sid:
  1466. X        tq->U.V22.tcelem = oldid(currsym.U.V1.vid, lidentifier);
  1467. X        break ;
  1468. X      case sarray:
  1469. X        error(econfconf);
  1470. X        tq->U.V22.tcelem = pconform();
  1471. X        break ;
  1472. X      default:
  1473. X        Caseerror(Line);
  1474. X    }
  1475. X    R141 = tp;
  1476. X    return R141;
  1477. X}
  1478. X
  1479. X treeptr
  1480. Xpsubpar()
  1481. X{
  1482. X    register treeptr    R142;
  1483. X    treeptr    tp, tq;
  1484. X    treetyp    nt;
  1485. X
  1486. X    tq = (struct S61 *)NIL;
  1487. X    do {
  1488. X        nextsymbol(*((symset *)Conset[86]));
  1489. X        switch (currsym.st) {
  1490. X          case sid:
  1491. X            nt = nvalpar;
  1492. X            break ;
  1493. X          case svar:
  1494. X            nt = nvarpar;
  1495. X            break ;
  1496. X          case sfunc:
  1497. X            nt = nparfunc;
  1498. X            break ;
  1499. X          case sproc:
  1500. X            nt = nparproc;
  1501. X            break ;
  1502. X          default:
  1503. X            Caseerror(Line);
  1504. X        }
  1505. X        if (nt != nvalpar)
  1506. X            nextsymbol(*((symset *)Conset[87]));
  1507. X        if (tq == (struct S61 *)NIL) {
  1508. X            tq = mknode(nt);
  1509. X            tp = tq;
  1510. X        } else {
  1511. X            tq->tnext = mknode(nt);
  1512. X            tq = tq->tnext;
  1513. X        }
  1514. X        switch (nt) {
  1515. X          case nvarpar:  case nvalpar:
  1516. X            tq->U.V14.tidl = pidlist(lidentifier);
  1517. X            tq->U.V14.tattr = anone;
  1518. X            checksymbol(*((symset *)Conset[88]));
  1519. X            if (nt == nvalpar)
  1520. X                nextsymbol(*((symset *)Conset[89]));
  1521. X            else
  1522. X                nextsymbol(*((symset *)Conset[90]));
  1523. X            switch (currsym.st) {
  1524. X              case sid:
  1525. X                tq->U.V14.tbind = oldid(currsym.U.V1.vid, lidentifier);
  1526. X                break ;
  1527. X              case sarray:
  1528. X                tq->U.V14.tbind = pconform();
  1529. END_OF_FILE
  1530. if test 34509 -ne `wc -c <'ptc.c.2'`; then
  1531.     echo shar: \"'ptc.c.2'\" unpacked with wrong size!
  1532. fi
  1533. # end of 'ptc.c.2'
  1534. fi
  1535. echo shar: End of archive 4 \(of 12\).
  1536. cp /dev/null ark4isdone
  1537. MISSING=""
  1538. for I in 1 2 3 4 5 6 7 8 9 10 11 12 ; do
  1539.     if test ! -f ark${I}isdone ; then
  1540.     MISSING="${MISSING} ${I}"
  1541.     fi
  1542. done
  1543. if test "${MISSING}" = "" ; then
  1544.     echo You have unpacked all 12 archives.
  1545.     rm -f ark[1-9]isdone ark[1-9][0-9]isdone
  1546. else
  1547.     echo You still need to unpack the following archives:
  1548.     echo "        " ${MISSING}
  1549. fi
  1550. ##  End of shell archive.
  1551. exit 0
  1552. -- 
  1553.  
  1554. Rich $alz            "Anger is an energy"
  1555. Cronus Project, BBN Labs    rsalz@bbn.com
  1556. Moderator, comp.sources.unix    sources@uunet.uu.net
  1557.